﻿using LJ.Abstractions.Exceptions;
using LJ.Abstractions.Extensions;
using LJ.MobilePush.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.MobilePush.Aliyun.Internal;

public class AliyunMobilePushFactory(IServiceProvider serviceProvider) : IMobilePushFactory
{

    private readonly IServiceProvider _serviceProvider = serviceProvider;


    public IMobilePush Create(string key)
    {
        var mobilePush = _serviceProvider.GetRequiredService<IMobilePush>();

        if (mobilePush is not AliyunMobilePush aliyunMobilePush)
        {
            throw new AppException($"{GetType().FullName} IMobilePush is not {nameof(AliyunMobilePush)}");
        }
        aliyunMobilePush.SetAppKey(key);
        return aliyunMobilePush;
    }
}
